package com.example.demo.service;

import com.example.demo.mapper.BlogInfoMapper;
import com.example.demo.model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Service
public class BlogInfoService {
    @Autowired
    private BlogInfoMapper blogInfoMapper;
    /*
    返回博客列表
     */
    public List<BlogInfo> select() {
        List<BlogInfo> blogInfos = blogInfoMapper.querySelectAll();
        return blogInfos;
    }

    public BlogInfo selectById(Integer id){
        BlogInfo blogInfo=blogInfoMapper.querySelectById(id);
        return blogInfo;
    }

    public Integer delete(Integer id) {
        Integer i = blogInfoMapper.queryDeleteById(id);
        return i;
    }

    public Integer update(BlogInfo blogInfo) {
        Integer i = blogInfoMapper.queryUpdate(blogInfo);
        return i;
    }

    public Integer insert(BlogInfo blogInfo) {
        Integer i = blogInfoMapper.insertBlog(blogInfo);
        return i;
    }

    public BlogInfo getBlogDetail(Integer blogId) {
        return blogInfoMapper.getBlogById(blogId);
    }
}
